//递归逆置字符串

int My_strlen(char* string)
{
	int count = 0;
	while (*string != '\0')
	{
		count++;
		string++;
	}
	return count;
}

//abcdef\0
 
//递归
void reverse_string(char* string)
{
	int len = My_strlen(string);
	char tmp = *string;
	*string = *(string + len-1);
	*(string + len-1) = '\0';
	if (My_strlen(string+1) >= 2)
	{
		reverse_string(string+1);
	}
	*(string + len-1 )= tmp;
}

int main()
{
	char arr[] = "abcdef";
	int len = My_strlen(arr);
	reverse_string(arr);
	printf("%s\n", arr);
	
	return 0;
}



//打印菱形
//6*6
int main()
{
	for (int i = 1; i <= 7; i++)
	{
		for (int j = 7-i; j > 0; j--)
		{
			printf(" ");
		}
		for (int k = 1; k <= 2 * i - 1; k++)
		{
			printf("*");
		}
		printf("\n");
	}
	for (int i = 1; i <= 6; i++)
	{
		for (int j = 1; j <= i; j++)
		{
			printf(" ");
		}
		for (int k = 1; k <= 13-2*i; k++)
		{
			printf("*");
		}
		printf("\n");
	}
	return 0;
}



//计算水仙数
#include<stdbool.h>
#include<math.h>
bool FindNum(int num, int n)
{
	int sum = 0;
	int tmp = num;
	while (tmp)
	{
		sum += pow(tmp % 10 ,n);
		tmp /= 10;
	}
	if (sum == num)
		return true;
	else
		return false;
}

int main()
{
	for (int i = 1; i < 100000; i++)
	{
		//计算位数
		int count = 0;
		int n = i;
		while (n)
		{
			n /= 10;
			count++;
		}

		if (FindNum(i, count))
		{
			printf("%d ",i);
		}
	}
	return  0;
}
